package net.lab1024.sa.admin.module.business.erp.controller;

import net.lab1024.sa.admin.module.business.erp.domain.form.add.AccountbAddForm;
import net.lab1024.sa.admin.module.business.erp.domain.form.query.AccountbQueryForm;
import net.lab1024.sa.admin.module.business.erp.domain.form.update.AccountbUpdateForm;
import net.lab1024.sa.admin.module.business.erp.domain.vo.AccountbVO;
import net.lab1024.sa.admin.module.business.erp.service.AccountbService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 生产订单与用户关系表 Controller
 *
 * @Author akita
 * @Date 2025-04-19 13:18:28
 * @Copyright akita
 */

@RestController
@Tag(name = "生产订单与用户关系表")
public class AccountbController {

    @Resource
    private AccountbService accountbService;

    @Operation(summary = "分页查询 @author akita")
    @PostMapping("/accountb/queryPage")
    @SaCheckPermission("accountb:query")
    public ResponseDTO<PageResult<AccountbVO>> queryPage(@RequestBody @Valid AccountbQueryForm queryForm) {
        return ResponseDTO.ok(accountbService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author akita")
    @PostMapping("/accountb/add")
    @SaCheckPermission("accountb:add")
    public ResponseDTO<String> add(@RequestBody @Valid AccountbAddForm addForm) {
        return accountbService.add(addForm);
    }

    @Operation(summary = "更新 @author akita")
    @PostMapping("/accountb/update")
    @SaCheckPermission("accountb:update")
    public ResponseDTO<String> update(@RequestBody @Valid AccountbUpdateForm updateForm) {
        return accountbService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author akita")
    @PostMapping("/accountb/batchDelete")
    @SaCheckPermission("accountb:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return accountbService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author akita")
    @GetMapping("/accountb/delete/{docEntry}")
    @SaCheckPermission("accountb:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long docEntry) {
        return accountbService.delete(docEntry);
    }
}
